#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ERROR_CHECK(ret, num, msg) \
    {                              \
        if (ret == num)            \
        {                          \
            perror(msg);           \
            exit(1);               \
        }                          \
    }
int main(int argc, char *argv[])
{
    FILE *fp = fopen("testbin", "rb+");
    int val[5] = {256, 12, 13, 15,10};
    fwrite(val, 4, 5, fp);
    fseek(fp, 0, SEEK_SET);
    int res[2] = {0};
    for (size_t i = 0; i < 5; i++)
    {
        fread(&res[i], 4, 1, fp);
        printf("%d\n", res[i]);
    }
    puts("--------");
    fseek(fp, 0, SEEK_SET);
    printf("ftell%ld\n",ftell(fp));
    fread(res, 4, 1, fp);
    printf("ftell%ld\n",ftell(fp));
    printf("%d\n", res[0]);
    char buf[32] = "AAAAAAAAAAAAA";
    fwrite(buf,1,strlen(buf),fp);
    printf("ftell%ld\n",ftell(fp));
    return 0;
}
